package io.wongxd.solution.permissionFlow

/**
 * State model of a permission
 *
 * @property permission Name of a permission
 * @property isGranted State of a permission whether it's granted or not
 */
data class PermissionState(val permission: String, val isGranted: Boolean)

/**
 * State model for multiple permissions
 *
 * @property permissions List of state of multiple permissions
 */
data class MultiplePermissionState(val permissions: List<PermissionState>) {

    /**
     * Returns true if all permissions are granted by user
     */
    val allGranted by lazy { permissions.all { it.isGranted } }

    /**
     * List of permissions which are granted by user
     */
    val grantedPermissions by lazy { permissions.filter { it.isGranted }.map { it.permission } }

    /**
     * List of permissions which are denied / not granted by user
     */
    val deniedPermissions by lazy { permissions.filter { !it.isGranted }.map { it.permission } }
}
